#include "menustate.h"

#include "window.h"
#include "gameapplication.h"
#include <QGridLayout>
#include "statemanager.h"

MenuState::MenuState()
{
	window_ = new MenuDialog();
	connect(window_, SIGNAL(closeGame()), GameApplication::instance(), SLOT(quit()));
	connect(window_, SIGNAL(startGame()), this, SLOT(startGame()));
	connect(window_, SIGNAL(showInstruction()), this, SLOT(showInstruction()));
}

MenuState::~MenuState() {
	delete window_;
}

void MenuState::enter() {
	Window::getLayout()->addWidget(window_,1,1);
	window_->show();
}

void MenuState::exit() {
	Window::getLayout()->removeWidget(window_);
	window_->hide();
}

void MenuState::startGame() {
	StateManager::getInstance().setState("game");
}

void MenuState::showInstruction() {
	StateManager::getInstance().setState("instruction");
}
